package com.bsoft.ecommerce.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

@Getter
@AllArgsConstructor
public enum GoodsStatus {

    ONLINE(101,"上线"),
    OFFINE(102,"下线"),
    STOCK_OUT(103,"缺货"),;
    private  final  Integer status;

    private final  String  description;

    public  static  GoodsStatus of(Integer status){
        Objects.requireNonNull(status);

        return Stream.of(values())
                .filter(bean->bean.status.equals(status))
                .findAny()
                .orElseThrow(()-> new IllegalArgumentException(status+"not exists"));
    }
}
